package com.learning.railwayreservation.action;

import java.lang.reflect.InvocationTargetException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.learning.railwayreservation.biz.CheckTicketsAvailibilty;
import com.learning.railwayreservation.formbeans.CheckAvailabilityForm;
import com.learning.railwayreservation.vo.AvailabilityDetailsVo;
import com.learning.railwayreservation.vo.CheckTicketsAvailibiltyInputVO;

public class CheckTicketAvailibilityAction extends Action {
	public ActionForward execute(ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception{
		
		CheckTicketsAvailibilty checkTicketsAvailibilty = new CheckTicketsAvailibilty();
		CheckAvailabilityForm checkAvailForm = (CheckAvailabilityForm) form;
		CheckTicketsAvailibiltyInputVO availibility2VO = new CheckTicketsAvailibiltyInputVO();
		BeanUtils.copyProperties( availibility2VO, checkAvailForm );
		AvailabilityDetailsVo availDetVo = checkTicketsAvailibilty.doTicketEnquiry(availibility2VO);
		request.setAttribute("seatDetails", availDetVo);

		return (mapping.findForward("success"));
		
	}

}
